#include "perspective_camera.h"

PerspectiveCamera::PerspectiveCamera(Point eye,Point at,Point up,float fovUp,float aspect,float dNear,float dFar)
	:	frustum(eye,at,up,fovUp,aspect,dNear,dFar){
	_fovUp = fovUp;
	_dNear = dNear;
	_dFar = dFar;
	_aspect = aspect;
}

PerspectiveCamera::~PerspectiveCamera(){

}

void PerspectiveCamera::applyCamera(){
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity ();
	gluPerspective(_fovUp*this->zoomFactor, _aspect, _dNear, _dFar);

	applyModelViewTransformations();
}

void PerspectiveCamera::addZoom(float factor){
	Camera::addZoom(factor);
	frustum.updateFrustum(frustum.getEye(),frustum.getAt(),this->getUp(),_fovUp*this->zoomFactor*PI/180,_aspect,_dNear,_dFar);
}

